# -*- coding: utf-8 -*-
from django.contrib.markup.templatetags import markup as django_markup
from django.template import Library
from django.conf import settings

register = Library()

def _markup(backend):
    def _inner():
        if backend == 'restructuredtext':
            return django_markup.restructuredtext
        elif backend == 'markdown':
            return django_markup.markdown
        elif backend == 'textile':
            return django_markup.textile
        else:
            assert False, "ImproperlyConfigured"
    return _inner()
markup = register.filter('markup', _markup(getattr(settings, 'WIKI_MARKUP', None)))
